package org.skatiger.jrove.component;

import java.io.Serializable;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

import org.skatiger.jrove.resource.Resource;

public class _ResourceList extends AbstractList<Resource> implements
        Serializable {
    /**
     * 
     */
    private static final long serialVersionUID = -6121007987960367126L;
    private List<Resource> _resources = new ArrayList<Resource>(5);
    private HashSet<String> _resourceValue = new HashSet<String>();

    @Override
    public void add(int index, Resource resource) {
        if (resource.getValue() != null
                && _resourceValue.contains(resource.getValue())) {
            return;
        }
        _resources.add(index, resource);
        _resourceValue.add(resource.getValue());
    }

    @Override
    public Resource get(int index) {
        return _resources.get(index);
    }

    @Override
    public int size() {
        return _resources.size();
    }

}
